import request, { postJson } from "@/apps/client/utils/request.ts";
const server = "/v1/user";
export function returnInstrument(data) {
    return postJson(server + `/returnInstrument`, data);
}


export function uploadInstrumentImage(file) {
    const formData = new FormData();
    formData.append('file', file.file); // file.file 是 Vant Uploader 提供的原始 File 对象

    return request.post(`${server}/uploadImg`, formData, {
        headers: {
            'Content-Type': 'multipart/form-data'
        }
    });
}


export function getInstruments() {
    return request.get(server + `/getInstruments`);
}
export function getLoanReviewers() {
    return request.get(server + `/getLoanReviewers`);
}

export function getInstrumentInfo(instrumentId) {
    return request.get(server + `/getInstrumentInfo?instrumentId=${instrumentId}`);
}
export function getInstrumentLoans(type, page, size) {
    return request.get(server + `/getInstrumentLoans?type=${type}&page=${page}&size=${size}`);
}

export function borrowInstrumentFromList(data) {
    return postJson(server + `/borrowInstrumentFromList`, data);
}
export function borrowInstrumentFromUp(data) {
    return postJson(server + `/borrowInstrumentFromUp`, data);
}

export function getInstrumentTimeSlots(data) {
    return request.post(server + `/getInstrumentTimeSlots`, data, {
        headers: {
            'Content-Type': 'application/json'
        }
    });
}

export function createInstrumentReservation(data) {
    return request.post(server + `/createInstrumentReservation`, data, {
        headers: {
            'Content-Type': 'application/json'
        }
    });
}
